﻿using UnityEngine;

namespace Jinndev {

    /// <summary>
    /// 对象池物体实例
    /// </summary>
    public class PoolItem : MonoBehaviour {

        [Tooltip("所属对象池")]
        public string poolName;

        /// <summary>
        /// 尝试回收，如无法回收则直接销毁
        /// </summary>
        public void Recycle() {
            if (CommonUtil.IsQuitting) {
                return;
            }

            if(PoolManager.Instance != null && PoolManager.Instance.Recycle(poolName, gameObject)) {
                return;
            }
            Destroy(gameObject);
        }

    }


}